package com.yuyou.train.gateway.controller;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;  import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yuyou.train.util.bean.ReturnCode;
import com.yuyou.train.util.bean.ReturnResult;
//@RestController  
public class ErrorHandlerController implements ErrorController {  
  
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
    /** 
     * 出异常后进入该方法，交由下面的方法处理 
     */  
    @Override  
    public String getErrorPath() {  
        return "/error";  
    }  
  
    @RequestMapping("/error")  
    public String error(HttpServletRequest http) { 
    	ReturnResult<String> res=new ReturnResult<String>(false,null,null,ReturnCode.code._2001.getCode(),ReturnCode.code._2001.getMessage()); 	
        return res.toJsonString();  
    }  
}
